package cn.zwx.mvcframework.webmvc.servlet;

import java.lang.reflect.Method;
import java.util.Objects;

/**
 * @author zhangwenxue
 */
public class ZwxHandlerMapping {
    /**
     * URL
     */
    private String pattern;
    /**
     * 对应的Method
     */
    private Method method;
    /**
     * Method对应的实例对象
     */
    private Object controller;

    public ZwxHandlerMapping(String patten, Method method, Object controller) {
        this.pattern = patten;
        this.method = method;
        this.controller = controller;
    }

    public String getPattern() {
        return pattern;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    @Override
    public String toString() {
        return "ZwxHandlerMapping{" +
                "patten='" + pattern + '\'' +
                ", method=" + method +
                ", controller=" + controller +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ZwxHandlerMapping that = (ZwxHandlerMapping) o;
        return Objects.equals(pattern, that.pattern) &&
                Objects.equals(method, that.method) &&
                Objects.equals(controller, that.controller);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pattern, method, controller);
    }
}
